package com.sumainfor.pc.market.controller;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.common.utlis.PageUtils;
import com.sumainfor.common.utlis.Pager;
import com.sumainfor.pc.market.dao.HousingConditionEvaMapper;
import com.sumainfor.pc.market.service.HousingConditionEvaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 查询特定条件的房源信息
 * <p>
 *
 * @author: zhoucong
 * @create: 2019-05-30 11:05
 **/
@Controller
@RequestMapping("/housingConditionEva")
public class HousingConditionEvaController {

   @Autowired
    HousingConditionEvaMapper housingConditionEvaMapper;

   @Autowired
    HousingConditionEvaService housingConditionEvaService;


   /**
   * <p>
   *查询已上架未出租的房源（分页查询）
   * </p>
   *
   * @author: zhoucong
   * @since:
   */

   @ResponseBody
   @PostMapping("/getHousCondEva")
   public JsonResult getHousCondEva(@RequestBody Map<String,Object> params, Pager pager){
       System.out.println("params"+params);
       pager.setPageno(Integer.parseInt(params.get("pageno").toString()));
       pager.setPagesize(Integer.parseInt(params.get("pagesize").toString()));
       pager.setPagerNecessary(params, pager);
       PageUtils pageUtils = new PageUtils();
       Integer cout=housingConditionEvaMapper.getHousCondEvaCount(params);
       if(cout==0){
           return pageUtils.getJsonResult(new ArrayList<Map<String,Object>>(), params,cout);
       }
       List<Map<String,Object>> getCommunityList=housingConditionEvaService.getHousCondEva(params);
       return pageUtils.getJsonResult(getCommunityList, params, cout);
   }



}
